<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增Keystore')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-app-add" name="form-app-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">应用名称：</label>
            <div class="col-sm-8">
                <input id="appName" name="appName" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">重定向地址：</label>
            <div class="col-sm-8">
                <input id="appUrl" name="appUrl" class="form-control" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">应用KEY：</label>
            <div class="col-sm-8">
                <input id="clientId" name="clientId" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">应用密钥：</label>
            <div class="col-sm-8">
                <input id="clientSecret" name="clientSecret" class="form-control" type="text" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">显示顺序：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="sort" id="sort" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "system/app";

    $("#form-app-add").validate({
        onkeyup: false,
        rules: {
            appName: {
                remote: {
                    url: prefix + "/checkAppNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "appName": function () {
                            return $.common.trim($("#appName").val());
                        }
                    }
                }
            },
            clientId: {
                remote: {
                    url: prefix + "/checkClientIdUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "clientId": function () {
                            return $.common.trim($("#clientId").val());
                        }
                    }
                }
            },
        },
        messages: {
            "appName": {
                remote: "应用名称已经存在"
            },
            "clientId": {
                remote: "clientId已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-app-add').serialize());
        }
    }
</script>
</body>
</html>
